package com.frxuexi.park

import android.view.View
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.frxuexi.lib_base.entity.ParkBeanItem
import com.frxuexi.park.databinding.ItemParkBinding

class ParkAdapter:BaseQuickAdapter<ParkBeanItem,BaseViewHolder>(R.layout.item_park) {
    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemParkBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: ParkBeanItem) {
        val binding = DataBindingUtil.getBinding<ItemParkBinding>(helper.itemView)!!
        binding.bean=item

        binding.parkStatus.apply {
            when(item.spaceStatus){
                "空闲"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_status)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.green))
                    binding.parkGroup.visibility=View.VISIBLE
                }
                "已占用"->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_zhanyong)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.blue))
                    binding.parkGroup.visibility=View.GONE
                }
                else->{
                    setBackgroundResource(com.frxuexi.lib_base.R.drawable.shape_weihu)
                    setTextColor(context.getColor(com.frxuexi.lib_base.R.color.darkorange))
                    binding.parkGroup.visibility=View.GONE
                }
            }
        }
    }
}